package com.design.AdapterMode.demo;

import java.util.ArrayList;
import java.util.List;

/**
 * 敏感词过滤1
 */
public class Filter1 {
    private static final List<String> sensitiveWords = new ArrayList<>(3);

    static {
        sensitiveWords.add("垃圾");
        sensitiveWords.add("擦");
        sensitiveWords.add("滚");
    }

    public String filter(Word word){
        if(null == word){
            return null;
        }
        sensitiveWords.forEach(v->{
            if(word.getWord().contains(v)){
                System.out.println("敏感词 ：" + v + ", 替换");
                word.getWord().replaceAll(v, word.getReplace());
            }
        });
        return word.getWord();
    }
}
